<template>
  <div class="top">
    <div class="left">
      <span class="lbtn" @click="goHome">首页</span>
    </div>
    <div class="center">
      <div class="title">智慧旅游可视化大数据展示平台</div>
      <div class="message">平台高峰预警信息(2条)</div>
    </div>
    <div class="right">
      <span class="rbtn">统计报告</span>
      <span class="time">当前时间：{{ time }}</span>
    </div>
  </div>
</template>

<script setup lang="ts" name="Top">
import { useRouter } from 'vue-router';
import moment from 'moment';
import { onBeforeUnmount, onMounted, ref } from 'vue';
//时间
let time = ref(moment().format('YYYY年MM月DD日 HH:mm:ss'));

let timer = ref<number>(0);
//时间定时器
onMounted(() => {
  timer.value = setInterval(() => {
    time.value = moment().format('YYYY年MM月DD日 HH:mm:ss');
  }, 1000);
});

//销毁定时器
onBeforeUnmount(() => {
  clearInterval(timer.value);
});

//跳转首页
let $router = useRouter();
const goHome = () => {
  $router.push('/');
};
</script>

<style lang="scss" scoped>
.top {
  width: 100%;
  height: 40px;
  display: flex;
  .left {
    flex: 1.25;
    background: url('../../../../assets/images/screen/dataScreen-header-left-bg.png') no-repeat;
    background-size: 100% 100%;
    .lbtn {
      float: right;
      width: 150px;
      height: 40px;
      background: url('../../../../assets/images/screen/dataScreen-header-btn-bg-l.png') no-repeat;
      background-size: cover;
      text-align: center;
      line-height: 40px;
      color: #29fcff;
      font-size: 20px;
      cursor: pointer;
    }
  }
  .center {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    .title {
      width: 100%;
      height: 74px;
      background: url('../../../../assets/images/screen/dataScreen-header-center-bg.png') no-repeat;
      background-size: cover;
      text-align: center;
      line-height: 74px;
      color: #29fcff;
      font-size: 30px;
    }
    .message {
      position: absolute;
      top: 72px;
      height: 44px;
      width: 622px;
      color: #fff;
      line-height: 44px;
      text-align: center;
      background: url('../../../../assets/images/screen/dataScreen-header-warn-bg.png') no-repeat;
      background-size: 100% 100%;
    }
  }
  .right {
    flex: 1.25;
    background: url('../../../../assets/images/screen/dataScreen-header-right-bg.png') no-repeat;
    background-size: 100% 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .rbtn {
      float: left;
      width: 150px;
      height: 40px;
      background: url('../../../../assets/images/screen/dataScreen-header-btn-bg-r.png') no-repeat;
      background-size: cover;
      text-align: center;
      line-height: 40px;
      color: #29fcff;
      font-size: 20px;
      cursor: pointer;
    }
    .time {
      color: #29fcff;
      font-size: 17px;
      margin-right: 10px;
    }
  }
}
</style>
